
#include "main.h"

/***************************************************************/
#define EX_INT0_NUM         0
#define TMR0_INT_NUM        1
#define TMR3_INT_NUM        16
#define TMR4_INT_NUM        15
#define EX_INT2_NUM         12
#define UART0_INT_NUM       4
#define UART1_INT_NUM       3
#define UART2_INT_NUM       5
#define UART3_INT_NUM       9

/***************************************************************/

/***************************************************************************************
* Function Name  : 定时器3
* Description    : 
* Input          : 
* Return         : 
* Not            : 
***************************************************************************************/

void Time3_INT() interrupt	TMR3_INT_NUM
{
//	gb_Tick1sFlag = 1;
}
/***************************************************************************************
* Function Name  : 定时器4
* Description    :
* Input          : 
* Return         : 
* Not            : 
***************************************************************************************/

void Time4_INT() interrupt	TMR4_INT_NUM
{
    static u8 t10ms_ct = 0;
	static u8 t600ms_ct = 0;
    static bool flag = 0;
	_push_(INSCON);
    SelectSFRBank0();	
    if (++t10ms_ct >= 10)
    {
        t10ms_ct = 0;
        base_10ms_f = true;
        
		t600ms_ct++;
		if(t600ms_ct== 60)
		{
			t600ms_ct = 0;
			gb_heattubedeal = 1;
		}
		flag = !flag;		
        u8_dn(&panel_comm.send_dly);
//        TEST_OUTPIN = !TEST_OUTPIN;           
    }
      
    u8_dn(&gu8_zerodelay);
    u8_dn(&gu8_zerodefault);   
    top_heater_power_ctr();
    outtop_heater_power_ctr();
    bomi_heater_power_ctr();
    left_heater_power_ctr();
    bomo_heater_power_ctr();    
    gb_heattubedeal = 0; 
    uart_byte_tmr_dn(&panel_comm);
    uart_byte_tmr_dn(&motor_comm);
    uart_byte_tmr_dn(&screen_comm);
    Euart_byte_tmr_dn(&speak_comm);
    Kuart_byte_tmr_dn(&kmos_comm);
    _pop_(INSCON);
}
void UART0_INT() interrupt  UART0_INT_NUM
{
	_push_(INSCON);
    SelectSFRBank0();
    if (RI == 1)
    {
        // TODO: Add your code here
        RI = 0;  //UART Recept Flag is clean by firmware( Write 0 to clean)
        uart_recv_byte_isr1(&screen_comm);
    }
    if (TI == 1)
    {
        // TODO: Add your code here.
        TI = 0;  //UART Recept Flag is clean by firmware( Write 0 to clean)
        uart_send_byte_isr1(&screen_comm);

//        TOGGLE_TEST_PIN = ~TOGGLE_TEST_PIN;
    }
	_pop_(INSCON);    
}
/***************************************************************************************
* Function Name  : 串口
* Description    :
* Input          : 
* Return         : 
* Not            : 
***************************************************************************************/
void UART1_INT() interrupt  UART1_INT_NUM
{
	_push_(INSCON);
    SelectSFRBank1();
    if (RI1 == 1)
    {
        // TODO: Add your code here
        RI1 = 0;  //UART Recept Flag is clean by firmware( Write 0 to clean)
        uart_recv_byte_isr(&panel_comm);
    }
    if (TI1 == 1)
    {
        // TODO: Add your code here.
        TI1 = 0;  //UART Recept Flag is clean by firmware( Write 0 to clean)
        uart_send_byte_isr(&panel_comm);

//        TOGGLE_TEST_PIN = ~TOGGLE_TEST_PIN;
    }
	_pop_(INSCON);    
}
/***************************************************************************************
* Function Name  : 串口
* Description    :
* Input          : 
* Return         : 
* Not            : 
***************************************************************************************/
void UART2_INT() interrupt  UART2_INT_NUM
{
	_push_(INSCON);
    SelectSFRBank1();
    if (RI2 == 1)
    {
        // TODO: Add your code here
        RI2 = 0;  //UART Recept Flag is clean by firmware( Write 0 to clean)
        uart_recv_byte_isr2(&motor_comm);
    }
    if (TI2 == 1)
    {
        // TODO: Add your code here.
        TI2 = 0;  //UART Recept Flag is clean by firmware( Write 0 to clean)
        uart_send_byte_isr2(&motor_comm);

    }
	_pop_(INSCON);    
}
/***************************************************************************************
* Function Name  : 串口1
* Description    :
* Input          : 
* Return         : 
* Not            : 
***************************************************************************************/
void UART3_INT() interrupt  UART3_INT_NUM
{
	_push_(INSCON);
    SelectSFRBank1();
    if (RI3 == 1)
    {
        // TODO: Add your code here
        RI3 = 0;  //UART Recept Flag is clean by firmware( Write 0 to clean)
         if((gu8_version == 0)&&(gu8_SystemBeginTime == 0))
         {
             Kuart_recv_byte_isr();
         }
         else
            Euart_recv_byte_isr();
    }
    if (TI3 == 1)
    {
        // TODO: Add your code here.
        TI3 = 0;  //UART Recept Flag is clean by firmware( Write 0 to clean)
        if((gu8_version == 0)&&(gu8_SystemBeginTime == 0))
        {
            Kuart_send_byte_isr();
        }
        else
            Euart_send_byte_isr();

    }
	_pop_(INSCON);    
}

void INT_INT3() interrupt  14
{
	static u8 temp = 0;
	static u8 ct = 0;

	_push_(INSCON);    
    SelectSFRBank0();
    EXF2 = 0; //中断标志位清零

    steamCtrl.powerErr_sec = 0;
    

    gu8_zerodelay = 10;
    gu8_zerodefault = 200;
//        TEST_OUTPIN = !TEST_OUTPIN;
        _pop_(INSCON); 
}





























